#include "StreamServerWidget.h"

StreamServerWidget::StreamServerWidget(void)
{
	createInterface();
}

StreamServerWidget::~StreamServerWidget(void)
{
}

void StreamServerWidget::createInterface()
{
	QHBoxLayout *pSubLayout = new QHBoxLayout();
	setTitle(tr(TITLE_SECTION_STREAM));

	QVBoxLayout *pSubLayout1 = new QVBoxLayout();
	QWidget *subWidget1 = new QWidget();
	QVBoxLayout *pSubLayout2 = new QVBoxLayout();
	QWidget *subWidget2 = new QWidget();
	m_lblServer = new QLabel(tr(LABEL_IC_SERVER));
	m_lblPort = new QLabel(tr(LABEL_IC_PORT));
	m_lblUser = new QLabel(tr(LABEL_IC_USER));
	m_lblMountPoint = new QLabel(tr(LABEL_IC_MOUNT));
	pSubLayout1->addWidget(m_lblServer);
	pSubLayout1->addWidget(m_lblPort);
	pSubLayout1->setContentsMargins(2, 0, 0, 0);
	subWidget1->setLayout(pSubLayout1);
	pSubLayout2->addWidget(m_lblMountPoint);
	pSubLayout2->addWidget(m_lblUser);
	pSubLayout2->setContentsMargins(2, 0, 0, 0);
	subWidget2->setLayout(pSubLayout2);
	pSubLayout->addWidget(subWidget1);
	pSubLayout->addWidget(subWidget2);
#if !defined(_WIN32) && !defined(_WIN64)
	pSubLayout->setContentsMargins(0, 5, 0, 5);
#endif
	setLayout(pSubLayout);
}

void StreamServerWidget::update(const IceCastSlot *slot)
{
	if (0 == slot)
		return;

	m_lblServer->setText(QString(LABEL_IC_SERVER) + QString(slot->host ? slot->host : "-"));
	m_lblPort->setText(QString(LABEL_IC_PORT) + (slot->port ? QString::number(slot->port) : "-"));
	m_lblUser->setText(QString(LABEL_IC_USER) + QString(slot->user ? slot->user : "-"));
	m_lblMountPoint->setText(QString(LABEL_IC_MOUNT) + QString(slot->mount ? slot->mount : "-"));
}

void StreamServerWidget::reset()
{
	m_lblServer->setText(QString(LABEL_IC_SERVER));
	m_lblPort->setText(QString(LABEL_IC_PORT));
	m_lblUser->setText(QString(LABEL_IC_USER));
	m_lblMountPoint->setText(QString(LABEL_IC_MOUNT));
}

